import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import 'package:sports_new/widgets/picker_local.dart';
import 'package:sports_new/widgets/base/qkd_button.dart';
import 'package:sports_new/widgets/base/qkd_text.dart';
import '../../resources/colours.dart';
import '../max_bottom_sheet.dart';

class QkdTimePicker extends StatelessWidget {
  const QkdTimePicker({super.key, required this.title});

  final String title;

  @override
  Widget build(BuildContext context) {
    DateTime time = DateTime.now();
    return MaxBottomSheet(
      onClosing: () {  },
      backgroundColor: Colours.white,
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(12)
      ),
      builder: (BuildContext context) =>
          Column(
            mainAxisSize: MainAxisSize.min,
            children: [
              QkdText(title,fontSize: 16).paddingSymmetric(vertical: 30),
              SizedBox(
                height: 147,
                child: Localizations.override(
                  context: context,
                  locale: const Locale("zh","CN"),
                  delegates: const [
                    PickerLocalizations.delegate
                  ],
                  child: CupertinoDatePicker(
                    use24hFormat: true,
                    itemExtent: 36,
                    mode: CupertinoDatePickerMode.dateAndTime,
                    minimumDate: DateTime.now(),
                    maximumDate: DateTime(DateTime.now().year,12,31,23,59,59),
                    maximumYear: DateTime.now().year,
                    onDateTimeChanged: (DateTime value) => time = value,
                  ),
                ),
              ),
              Padding(
                padding: const EdgeInsets.only(
                    top: 30, bottom: 20, left: 16, right: 16
                ),
                child: Row(
                    children: [
                      Flexible(
                        child: QkdButton(
                          width: double.infinity,
                          height: 44,
                          backgroundColor: Colours.greyF2,
                          foregroundColor: Colours.grey66,
                          borderRadius: 8,
                          onPressed: () {
                            navigator?.pop();
                          },
                          text: '取消',
                        ),
                      ),
                      const SizedBox(width: 16),
                      Flexible(
                        child: QkdButton(
                          width: double.infinity,
                          height: 44,
                          backgroundColor: Colours.main,
                          foregroundColor: Colours.white,
                          borderRadius: 8,
                          onPressed: () => navigator?.pop(time),
                          text: '确定',
                        ),
                      )
                    ]
                ),
              ),
            ],
          ),
    );;
  }
}
